package com.white.mybatis.dynamic;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.white.mybatis.dynamic.support.proxy.AbstractProxy;
import java.lang.reflect.Method;

/**
 * <p>
 * Wrapper代理
 * </p>
 *
 * @author huangzy
 * @since 2022/3/16
 */
public class ProxyWrapper extends AbstractProxy<QueryWrapper<?>,QueryWrapper<?>> {

    @Override
    public void enhance(Object source, Method method, Object[] args) {

    }

    @Override
    public Object postposition(Object source, Method method, Object[] args, Object result) {
        if ("getSqlSegment".equals(method.getName()) && method.getParameterCount() == 0) {
            return String.valueOf(result).replace("_",".");
        }
        if ("getTargetSql".equals(method.getName()) && method.getParameterCount() == 0) {
            return String.valueOf(result).replace("_",".");
        }
        return result;
    }

    @Override
    public Object exceptionHandle(Object source, Method method, Object[] args, Throwable e) throws Throwable {
        return null;
    }
}
